#include<iostream>
#include<array>
#include<cstring>
using namespace std;

void handle_1() {
    cout << "Enter two numbers: " << endl;
    int numMin, numMax;
    cout << "Min is: ";
    cin >>numMin;
    cout << "Max is: ";
    cin >> numMax;
    int sum = 0;
    for (int i = numMin; i <= numMax; i++) {
        sum += i;
    }
    cout << "The sum is " << sum << endl;
}

void handle_2() {
    const int arrSize = 101;
    array<long double, arrSize> list;
    int i;
    list[0] = list[1] = 1;
    cout << "0! =" << list[0] << endl;
    cout << "1! =" << list[1] << endl;
    for (i = 2; i < arrSize; i++) {
        list[i] = i * list[i - 1];
        cout << i << "! =" << list[i] << endl;
    }
}

void handle_3() {
    int sum = 0;
    int num;
    cout << "Enter number: ";
    cin >> num;
    while (num != 0) {
        sum += num;
        cout << "The sum is " << sum << endl;
    }
    cout << "End" << endl;
}

void handle_4() {
    double sum1, sum2;
    int year = 0;
    sum1 = 100;
    sum2 = 100;
    while (sum1 >= sum2) {
        year++;
        sum1 += 100 * 0.1;
        sum2 += sum2 * 0.05;
    }
    cout << year << " years later, Cleo will have more monet than Daphne" << endl;
    cout << "Then, Cleo will have $" << sum2 << ",and Daphne will have $" << sum1 << endl;
}

void handle_5() {
    int sellNum[12];
    int sum = 0;
    const char* months[12] = {
        "January",
        "February",
        "March",
        "April",
        "May",
        "June",
        "July",
        "August",
        "September",
        "October",
        "November",
        "December"
    };
    for (int i = 0; i < 12; i++) {
        cout << months[i] << ": ";
        cin >> sellNum[i];
        sum += sellNum[i];
    }
    cout << "This year, " << sum << "books are sold" << endl;
}

void handle_6() {
    int sellNum[3][12];
    const char* months[12] = {
        "January",
        "February",
        "March",
        "April",
        "May",
        "June",
        "July",
        "August",
        "September",
        "October",
        "November",
        "December"
    };
    int sum[3] = {0};
    int totalSum = 0;
    for (int j = 0; j < 3; j++) {
        for (int i = 0; i < 12; i++) {
            cout << months[i] << ": ";
            cin >> sellNum[j][i];
            sum[j] += sellNum[j][i];
        }
        totalSum += sum[j];
    }
    cout << "The first year's sales were " << sum[0] << " books" << endl;
    cout << "The second year's sales were " << sum[0] << " books" << endl;
    cout << "The third year's sales were " << sum[0] << " books" << endl;
    cout << "The total sales revenue is " << totalSum << " books" << endl;
}

struct Car{
    string brand;
    int birth;
};

void handle_7() {
    cout << "How many cars do you wish to catalog? ";
    int num;
    cin >> num;
    Car* carList = new Car[num];
    for (int i = 0; i < num; i++) {
        cout << "Car #" << i + 1 << ":" << endl;
        cout << "Please enter the make: ";
        cin.get();
        getline(cin, carList[i].brand);
        cout << "Please enter the year made: ";
        cin >> carList[i].birth;
    }
    cout << "Here is your collection:" << endl;
    for (int i = 0; i < num; i++) {
        cout << carList[i].birth << " " << carList[i].brand << endl;
    }
}

void handle_8() {
    char word[100];
    cout << "Enter words (to stop, typethe word done):" << endl;
    cin >> word;
    int count = 0;
    while (strcmp(word, "done") != 0) {
        if (bool(cin >> word)) count++;
    }
    cout << "You entered a total of " << count << " words" << endl;
}

void handle_9() {
    string word;
    cout << "Enter words (to stop, typethe word done):" << endl;
    cin >> word;
    int count = 0;
    while (word !="done") {
        if (bool(cin >> word)) count++;
    }
    cout << "You entered a total of " << count << " words" << endl;
}

void handle_10() {
    cout << "Enter number of rows: ";
    int row;
    cin >> row;
    for (int i = 1; i <= row; i++) {
        for (int j = row - i; j >= 0; j--) {
            cout << ".";
        }
        for (int k = 0; k < i; k++) {
            cout << "*";
        }
        cout << endl;
    }
}
